package com.bjtech.web.action.management;

import com.bjtech.dao.BaseCityInfoDao;
import com.bjtech.domain.BaseCityInfo;
import com.bjtech.domain.query.BaseCityInfoQuerySpec;
import com.bjtech.web.action.LyheatBaseAction;

public class BaseCityInfoAction extends LyheatBaseAction {

	private static final long serialVersionUID = 1L;
	private BaseCityInfoDao baseCityInfoDao;
	private BaseCityInfoQuerySpec selectBean;
	
	public void prepare() throws Exception {

	}
	
	public BaseCityInfoAction() throws Exception{
		model = new BaseCityInfo();
		selectBean = new BaseCityInfoQuerySpec();
	}
	
	public void setBaseCityInfoDao(BaseCityInfoDao baseCityInfoDao) {
		this.baseCityInfoDao = baseCityInfoDao;
	}

	public String execute(){
		return this.list();
	}
	
	public String list(){
		selectBean.queryParamString();
		list = this.baseCityInfoDao.selectEntityPaginatedList(new BaseCityInfo(),selectBean);
		return "list";
	}
	
	public String add(){
		return "edit";
	}
	
	public String save(){
		BaseCityInfo entity = (BaseCityInfo)model;
		if(entity.getId()==null){
			baseCityInfoDao.insertEntity(entity);
		}else{
			baseCityInfoDao.updateEntity(entity);
		}
		return "success";
	}
	
	public String edit(){
		model = this.baseCityInfoDao.selectEntity(new BaseCityInfo(),id);
		return "edit";
	}

	public String view(){
		model = this.baseCityInfoDao.selectEntity(new BaseCityInfo(),id);
		return "view";
	}
	
	public String delete(){
		model = this.baseCityInfoDao.deleteEntity(new BaseCityInfo(),id);
		return "success";
	}
	
	public BaseCityInfoQuerySpec getSelectBean() {
		return selectBean;
	}

	public void setSelectBean(BaseCityInfoQuerySpec selectBean) {
		this.selectBean = selectBean;
	}
}
